﻿namespace UnityEditor
{
    using System;
    using UnityEngine;

    internal class ValueSmoother
    {
        private float m_CurrentValue = 0f;
        private float m_LastUpdateTime = Time.realtimeSinceStartup;
        private float m_TargetValue = 0f;

        public float GetSmoothValue()
        {
            return this.m_CurrentValue;
        }

        public void SetTargetValue(float value)
        {
            this.m_TargetValue = value;
            if (value == 0f)
            {
                this.m_CurrentValue = 0f;
            }
        }

        public void Update()
        {
            if (this.m_CurrentValue < 1f)
            {
                float num = Mathf.Clamp((float) (Time.realtimeSinceStartup - this.m_LastUpdateTime), (float) 0f, (float) 0.1f);
                float num2 = 1f;
                float num3 = num2 * num;
                this.m_CurrentValue = (this.m_CurrentValue * (1f - num3)) + (this.m_TargetValue * num3);
                if (this.m_CurrentValue > 0.995f)
                {
                    this.m_CurrentValue = 1f;
                }
            }
            this.m_LastUpdateTime = Time.realtimeSinceStartup;
        }
    }
}

